﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UguiModelCanvas : MonoBehaviour
{
    void LateUpdate()
    {
        UnityEngine.Canvas canvas = this.GetComponent<UnityEngine.Canvas>();
        if(!canvas.overrideSorting)
        {
            return;
        }

        Renderer[] renders = this.GetComponentsInChildren<Renderer>();
        for(int i = 0; i < renders.Length; i++)
        {
            renders[i].sortingOrder = canvas.sortingOrder;
            renders[i].sortingLayerID = canvas.sortingLayerID;
        }
        
    }
}
